const app = getApp();
Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    gridCol:3,
    skin: false,
    topic_list:[],
    topic_id:0,
  },

  onLoad:function(){
    this.get_topic();
  },

  //关键字搜索
  formSubmit:function(e){
    let _this = this,
     keyword = e.detail.value.keyword;
     if(keyword == ''){
      app.showError("关键字不能为空")
     }else{
      app._post('api/index/get_topic', {keyword:keyword}, function(result) {
        _this.setData({
          topic_list:result.data,
        })
      });
     }
  },

  //获取话题列表
  get_topic:function(){
    let _this = this;
    app._post('api/index/get_topic', {}, function(result) {
      _this.setData({
        topic_list:result.data,
      })
    });
  },

  //点击选中的话题
  topic_chose:function(e){
    let _this = this,
     topic_id = e.currentTarget.dataset.topicId;
     _this.setData({
      topic_id:topic_id
     })
     wx.navigateTo({
      url: './publish?topic_id='+topic_id
     })
  },
})